/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread =new Thread(()->{
            //while(!Thread.currentThread().isInterrupted()){  //这个也可以
            while(!Thread.interrupted()){
                System.out.println("thread线程");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
        });
        thread.start();
        Thread.sleep(3000);
        thread.interrupt();
    }
}
